package com.ysh.controller;

import com.ysh.domain.Order;
import com.ysh.domain.User;
import com.ysh.service.OrderService;
import com.ysh.service.impl.OrderServiceImpl;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class OrderController {
    OrderService orderService = new OrderServiceImpl();
    // 2.添加订单信息
    @Test
    public void insertOrder(){
        Order order  = new Order("o004",5,"u003");
        int result =orderService.addOrder(order);
        if (result != 0){
            System.out.println("添加订单，成功！");
        } else{
            System.out.println("添加订单，失败！");
        }
    }
    // 5.查询订单信息
    @Test
    public void findOrders(){
        // 集合对象存储User对象
        List<Order> list = new ArrayList<>();
        // 调用业务层，得到查询结果的list集合
        list = orderService.findUser();
        // 遍历输出
        for (Order order : list) {
            System.out.println(order);
        }
    }
}
